/*
 * Copyright 2011 Philippe Blanc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package me.l1k3.fx.client.impl;

import me.l1k3.core.client.queue.Queue;
import me.l1k3.fx.client.inter.FXShowAndHide;

/**
 * @exclude
 */
public abstract class FXShowAndHideAbstract extends FXAbstract implements FXShowAndHide {
    @Override
    public FXShowAndHide show() {
        if(!isVisible()) {
            toggle();
        }
        return this;
    }
    
    @Override
    public Queue show(int time) {
        return show(time, 0, false);
    }
    
    @Override
    public Queue show(int time, int delay, boolean toggle) {
        cancel();
        
        if(!isVisible()) {
            animate(time, delay, false);
        }
        else 
        if(toggle) {
            animate(time, delay, true);
        }
        
        return this;
    }
    
    @Override
    public FXShowAndHide hide() {
        if(isVisible()) {
            toggle();
        }
        return this;
    }
    
    @Override
    public Queue hide(int time) {
        return hide(time, 0, false);
    }
    
    @Override
    public Queue hide(int time, int delay, boolean toggle) {
        cancel();
        
        if(isVisible()) {
            animate(time, delay, false);
        }
        else
        if(toggle) {
            animate(time, delay, true);
        }
        
        return this;
    }
}
